﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Wijmo.Master" AutoEventWireup="true" CodeBehind="ObjectModel.aspx.cs" Inherits="ControlExplorer.C1TreeView.ObjectModel" %>

<%@ Register Assembly="C1.Web.Wijmo.Controls.3" Namespace="C1.Web.Wijmo.Controls.C1TreeView" TagPrefix="wijmo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
    <script type="text/javascript">
        function getNode() {
            return $("#<%= C1TreeView1.ClientID %>").c1treeview("findNodeByText", "文件夹 1"); ;
        }

        function add() {
            var node = getNode();
            if (node != null)
                node.element.c1treeviewnode("add", '新节点', parseInt($("#addIndex").val()));
        }

        function remove() {
            var node = getNode();
            if (node != null)
                node.element.c1treeviewnode("remove", parseInt($("#removeIndex").val()));
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <wijmo:C1TreeView ID="C1TreeView1" runat="server">
        <Nodes>
            <wijmo:C1TreeViewNode Text="文件夹 1">
                <Nodes>
                    <wijmo:C1TreeViewNode Text="文件夹 1.1">
                    </wijmo:C1TreeViewNode>
                    <wijmo:C1TreeViewNode Text="文件夹 1.2">
                    </wijmo:C1TreeViewNode>
                    <wijmo:C1TreeViewNode Text="文件夹 1.3">
                    </wijmo:C1TreeViewNode>
                    <wijmo:C1TreeViewNode Text="文件夹 1.4">
                    </wijmo:C1TreeViewNode>
                </Nodes>
            </wijmo:C1TreeViewNode>
        </Nodes>
    </wijmo:C1TreeView>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Description" runat="server">
    <p>
        此示例展示了如何从客户端的<strong>C1TreeView </strong>动态添加/移除节点。</p>
    <p>
        示例中应用了如下的客户端行为。</p>
    <ul>
        <li>add（添加）</li>
        <li>remove（移除）</li>
    </ul>
    <p>
        add具有以下参数。</p>
    <ul>
        <li><strong>node</strong> - <strong>node</strong>参数指定标记/jQuery的对象/树节点选项，添加到<strong>C1TreeView</strong> 或者 <strong>C1TreeViewNode</strong>。</li>
        <li><strong>index</strong> - <strong>index</strong>参数指定它的姊妹索引。如果<strong>index</strong>值为空，那么这些节点会加在末端。</li>
    </ul>
    <p>
        remove具有以下参数。</p>
    <ul>
        <li><strong>index</strong> - <strong>index</strong>参数指定<strong>C1TreeView</strong> 或<strong>C1TreeViewNode</strong>孩子节点的索引。</li>
    </ul>
    <p>
        例如：
        <pre>$("#treeId").c1treeviewnode("add", 'Node text 1');</pre>
    </p>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ControlOptions" runat="server">
    <div>
        <input id="addNode" onclick="add();" type="button" value="添加" />
        在索引
        <input id="addIndex" type="text" value="0" />
    </div>
    <div>
        <input id="removeNode" onclick="remove();" type="button" value="移除" />
        在索引
        <input id="removeIndex" type="text" value="0" />
    </div>
</asp:Content>
